// qdc.C -- qdcs of the plastic scintillators
void a(vector<TH1 *> &v, TObject *h){ v.push_back((TH1F *)h); }
void qdc(){
  TFile *f = new TFile(getenv("TMP1"));
  TTree *etf = (TTree *)f->Get("etf");
  vector<TH1 *> v;
  TH1 *h;
  TCut cut0 = "tstop.fired()==4";
  TCut cut1 = "tofwB.fired()==4";

  TCanvas *c = new TCanvas("c", "Amplitude related info - ADCs and QDCs", 1680, 1050);
  c->Divide(3, 3);
  c->cd(1); etf->Draw("tstop.ql()>>h1(500, 0., 5000.)", cut0);
  c->cd(2); etf->Draw("tstop.qr()>>h2(500, 0., 5000.)", cut0);
  c->cd(3); etf->Draw("tstop.q()>>h3(500, 0., 5000.)", cut0);
  f->GetObject("h3", h); h->SetTitle("Tstop\\,\\,->\\,\\,\\sqrt{QL*QR}");
  c->cd(4); etf->Draw("tofwB.ql():tofwB.stripId()>>h4(17, -1.5, 15.5, 500, 0., 5000.)", cut1, "colz");
  f->GetObject("h4", h); h->SetTitle("TOFWall QL");
  h->GetXaxis()->SetTitle("strip Id"); h->GetYaxis()->SetTitle("TOFW QL");
  c->cd(5); etf->Draw("tofwB.qr():tofwB.stripId()>>h5(17, -1.5, 15.5, 500, 0., 5000.)", cut1, "colz");
  f->GetObject("h5", h); h->SetTitle("TOFWall QR");
  h->GetXaxis()->SetTitle("strip Id"); h->GetYaxis()->SetTitle("TOFW QR");
  c->cd(6); etf->Draw("tofwB.q():tofwB.stripId()>>h6(17, -1.5, 15.5, 500, 0., 5000.)", cut1, "colz");
  f->GetObject("h6", h); h->SetTitle("TOFWall\\,\\,->\\,\\,\\sqrt{QL*QR}");
  h->GetXaxis()->SetTitle("strip Id"); h->GetYaxis()->SetTitle("TOFW Q");
  c->cd(7); etf->Draw("tstop.q():mu0>>h7(500, 0., 5., 500, 0., 5000.)", cut0, "colz");
  f->GetObject("h7", h); h->SetTitle("Tstop Q vs MUSIC 0");
  h->GetXaxis()->SetTitle("MUSIC 0"); h->GetYaxis()->SetTitle("Tstop Q");
  c->cd(8); etf->Draw("tofwB.q():mu1>>h8(500, 0., 5., 500, 0., 5000.)", cut1, "colz");
  f->GetObject("h8", h); h->SetTitle("TOFWall Q vs MUSIC 1");
  h->GetXaxis()->SetTitle("MUSIC 1"); h->GetYaxis()->SetTitle("TOFW Q");
  c->cd(9); etf->Draw("tstop.q():pdcTaUWire[0][0]>>h9(36, -45., 45., 500, 0., 5000.)",
    cut0 && "pdcTaUWire[0][0] !=-999.", "colz");
  f->GetObject("h9", h); h->SetTitle("Tstop Q vs x_ETF");
  h->GetXaxis()->SetTitle("x @ETF [mm]"); h->GetYaxis()->SetTitle("Tstop Q");

  c->Print("qdc.pdf");
} // end function qdc
